<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars 
define("PRIMARY_KEY","kdcust");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_transaction_custlist.php";
if (GetParam("Template","")=="DN") $FileTemplate = "ais_transaction_custlist_listdn.html";
elseif ((GetParam("FormName","")=="MemorialTransForm") && !GetParam("SendToBack","")) $FileTemplate = "ais_transaction_custlist_memotrans.html";
elseif ((GetParam("FormName","")=="CashBankForm" ) && !GetParam("SendToBack","")) {$FileTemplate = "ais_transaction_custlist_cashbanktrans.html";}
elseif ((GetParam("FormName","")=="CashBankPaymentForm") && !GetParam("SendToBack","")) {$FileTemplate = "ais_transaction_custlist_cashbanktrans_pay.html";}
elseif ((GetParam("FormName","")=="CNSummaryForm") && !GetParam("SendToBack","")) {$FileTemplate = "ais_transaction_custlist_dnlist.html";}
else $FileTemplate  = "ais_transaction_custlist_list.html";


$curr = GetParam("curr","");
$flag = GetParam("flag","");

$PageSize      = 10 ;
$TableName     = "tbldebtur";
$HTMLGridList  = "DebturGrid";

//************ FORM ACTION **************
	if (GetParam("Action","")=="Delete") {
		DeleteRecord ("txtCheck",$PageSize);
	}

$PreserveGet = GetQueryString("All", array("PageNum"));
//Initiate Database Table For Search;
$FNama = GetParam("debturSearch","");
$FCode = GetParam("debturCodeSearch","");
$transDate = GetParam("transDate","");

$FormName = GetParam("FormName","");
//******* DATABASE FORM QUERY ***********
$SQL = "SELECT * FROM $TableName ";
$SQLCount = "SELECT count(*) FROM $TableName ";

if ($FNama) 
	if (strlen($WHERE)) $WHERE .= " AND "." cuname like '%".$FNama."%'";
	else $WHERE .= " cuname like '%".$FNama."%'";	
if ($FCode) 
	if (strlen($WHERE)) $WHERE .= " AND "." cudebtur like '%".$FCode."%'";
	else $WHERE .= " cudebtur like '%".$FCode."%'";

	if (strlen($WHERE))	$WHERE = " WHERE ".$WHERE;
	else $WHERE = " WHERE 1";

$SQL = $SQL.$WHERE;
$SQLCount = $SQLCount.$WHERE;

//******* SHOW FORM CONTENT *********

//$PageNum = 1;
//$RecCnt = $DBConnection->dbc->get_var($SQLCount) ; 
//if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");

if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");
//Default value
if (!isset($_GET)) $_GET=&$HTTP_GET_VARS ;
if (isset($_GET['PageNum'])) {
  $PageNum = $_GET['PageNum'] ;
} else {
    $PageNum = 1 ;
}

//Default value
if (isset($_GET['RecCnt'])) {
  $RecCnt = intval($_GET['RecCnt']) ;
} else {
    $RecCnt = -1 ;
} 


$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("bln",$KEY);
$RecCnt = $TBS->MergeBlock("blg",$DBMysql,$SQL,$PageSize,$PageNum,$RecCnt);
$TBS->MergeNavigationBar('nv',array('size'=>10,'pos'=>'centred'),$PageNum,$RecCnt,$PageSize) ; 
$TBS->Show();



?>
